import {MyHttpStatusEnum} from "./enum/MyHttpStatusEnum";

export class Result<T> {
    success: boolean
    code: number
    msg: string
    data: T


    constructor(success?: boolean, code?: number, msg?: string, data?: T) {
        this.success = success;
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static success(msg?:string, data?:any) {
        return new Result(true, MyHttpStatusEnum.SUCCESS, msg || "成功", data)
    }

    public static failed(msg?:string, data?:any) {
        return new Result(false, MyHttpStatusEnum.FAILED, msg || "失败", data)
    }

}

